/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iluscodelogica;




import java.util.Hashtable;


public class Accion extends Instruccion {

    static Hashtable hashAccion = new Hashtable();
    private static final long serialVersionUID = 1L;

    public Accion(String descripcion) {
        super(descripcion);
        String token = descripcion.toLowerCase().intern();
        hashAccion.put(token, this);

    }
    
   

    public String toString() {

        return "Accion " + descripcion;
    }

    public String getToken() {

        return getDescripcion();
    }

    
     public TipoToken getId() {
	return TipoToken.ACCION;
    }
    
   

    static {
       try {
            Class.forName("iluscodelogica.Detecta");
        } catch (Exception e) {
        }
        new Accion("avanzar") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
                mv.getRobot().avanzar();
                //mv.getCrobot().avanzar();
                return true;
            }
        };
        new Accion("girarnorte") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
                
                mv.getRobot().girarNorte();
                
                return  true;
            }
        };
        new Accion("girarsur") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
                mv.getRobot().girarSur();
                return true;
            }
        };
        new Accion("girareste") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
                
                mv.getRobot().girarEste();
                
                return true;
            }
        };
        new Accion("giraroeste") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
                mv.getRobot().girarOeste();
               
                return true;
            }
        };
        
        new Accion("detener") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
                mv.getRobot().detener();
                return true;
            }
        };
        
         new Accion("cerrarcerramiento") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
               mv.getRobot().cerrarCerramiento();
                return true;
            }
        };
         
          new Accion("activaralarma") {
            private static final long serialVersionUID = 1L;

            public boolean ejecutar(MaquinaVirtual mv) {
                mv.getRobot().activarAlarma();
                return true;
            }
        };



    }

    ;
   
   public static Accion buscarAccion(String s) {

        return (Accion) hashAccion.get(s);
    }
}
